﻿using KZ.Express.ENT;
using KZ.Express.Task;
using KZ.Utilities;
using System;
using System.Data;

namespace KZ.Express.Presenter
{
    public interface IStatisticView : IViewBase
    {
        DataTable SupplierCarrier { set; }
    }

    public class StatisticPresenter : PresenterBase
    {
        private new IStatisticView _view;
        private new OrderStatisticTask _task;

        public StatisticPresenter(IStatisticView view)
            : base(view, new OrderStatisticENT())
        {
            _view = view;
            _task = new OrderStatisticTask();
        }

        public void LoadSupplierCarrier()
        {
            try
            {
                _view.SetMessage(String.Empty, true);
                _view.SupplierCarrier = _task.LoadSupplierCarrier();
            }
            catch (DataAccessException ex)
            {
                throw new BusinessLogicException(ex.Message);
            }
        }
    }
}